package com.example.qxfw.nyqx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.ny.CropGrowdateFcst;
import com.example.qxfw.nyqx.vo.GrowdateFcstListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
@DS("Service")
public interface CropGrowdateFcstMapper extends BaseMapper<CropGrowdateFcst> {

    @Select("select year, forecastdate " +
            "from crop_growdate_fcst " +
            "where year>= #{year1} and year<= #{year2} and stationid = '${stationId}' and type like '%${type}%' and cropname='${cropName}' and growdatename='${growDateName}' " +
            "order by year")
    List<GrowdateFcstListVo> selectList2(long year1, long year2, String stationId, String type, String cropName, String growDateName);

    @Select("select stationid, forecastdate, growdatename " +
            "from crop_growdate_fcst " +
            "where year='${year}' and cropname='${cropName}' " +
            "and ( type like '%${type}%' or type isnull ) " +
            "and ( growdatename like '%${growDateName}%' or growdatename is null ) ")
    List<CropGrowdateFcst> selectList1(String year,String cropName,String type,String growDateName);

    @Select("select * " +
            "from crop_growdate_fcst " +
            "where year='${year}' and cropname='${cropName}' " +
            "and ( type like '%${type}%' or type isnull ) " +
            "and ( growdatename like '%${growDateName}%' or growdatename is null ) ")
    List<CropGrowdateFcst> selectList3(long year,String cropName,String type,String growDateName);

    @Select("select forecastdate " +
            "from crop_growdate_fcst " +
            "where year = '${year}' and stationid = '${stationId}' and (type='${type}'or type is null) and cropname='${cropName}' and growdatename='${growDateName}'")
    List<String> selectForecastDate(String year,String stationId,String type,String cropName,String growDateName);

    @Select("select forecastdate " +
            "from crop_growdate_fcst " +
            "where year = '${year}' and stationid = '${stationId}' and (type='${type}'or type is null) and cropname='${cropName}' " +
            "order by forecastdate desc")
    List<String> selectForecastDate1(String year,String stationId,String type,String cropName);

    @Select("select forecastdate " +
            "from crop_growdate_fcst " +
            "where year = '${year}' and stationid = '${stationId}' and (type='${type}'or type is null) and growdatename='${growDateName}'")
    List<String> selectForecastDate2(String year,String stationId,String type,String growDateName);

}
